package com.acme.bankapp.domain.bank;


public class CheckingAccount extends AbstractAccount {

	private double overdraft;
	
	public CheckingAccount(double amount, double overdraft) {
		super(amount);
		this.overdraft = ((overdraft > 0) ? overdraft : 0);
	}
	
	@Override
	public void deposit(double amount) {
		if(amount >= 0) {
			this.balance += amount;
		} else {
			System.out.println("You can't deposite negative amount!");
		}
	}
	
	@Override
	public void withdraw(double amount) {
		if(amount >= 0) {
			if (this.balance + this.overdraft >= amount) {
				this.balance -= amount;
			} else {
				this.balance = -this.overdraft;
				System.out.println("You have no money to withdraw!");
			}
		} else {
			System.out.println("You can't withdraw negative amount!");
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		return this.balance + this.overdraft;
	}

	@Override
	public String getAccountType(Account account) {
		return "CheckingAccount";
	}

}
